// =====================================================================================
// 
//       Filename:  rational.h
// 
//    Description:  
// 
//        Version:  1.0
//        Created:  21.10.2011 14:33:40
//       Revision:  none
//       Compiler:  g++
// 
//         Author:  Dmitriy Serdyuk (), serdyuk.dmitriy@gmail.com
//        Company:  
// 
// =====================================================================================

#ifndef RATIONAL_H
#define RATIONAL_H

class Rational;   
Rational operator+(const Rational& r1, const Rational r2);
Rational operator-(const Rational& r1, const Rational r2);
Rational operator*(const Rational& r1, const Rational r2);
Rational operator/(const Rational& r1, const Rational r2);

Rational operator+=(const Rational& r1, const Rational r2);
Rational operator-=(const Rational& r1, const Rational r2);
Rational operator/=(const Rational& r1, const Rational r2);
Rational operator*=(const Rational& r1, const Rational r2);

bool operator==(const Rational& r1, const Rational& r2);
bool operator!=(const Rational& r1, const Rational& r2);
bool operator<=(const Rational& r1, const Rational& r2);
bool operator>=(const Rational& r1, const Rational& r2);
bool operator<(const Rational& r1, const Rational& r2);
bool operator>(const Rational& r1, const Rational& r2);

Rational operator++(Rational& r);


class Rational {
public:
    Rational(int p, int q = 1);

    operator double();
    Rational operator++(int);
private:
    int myP; //
    int myQ; // r = P / Q
    friend Rational operator+(const Rational& r1, const Rational r2);
    friend Rational operator-(const Rational& r1, const Rational r2);
    friend Rational operator*(const Rational& r1, const Rational r2);
    friend Rational operator/(const Rational& r1, const Rational r2);

    friend Rational operator+=(Rational& r1, const Rational r2);
    friend Rational operator-=(Rational& r1, const Rational r2);
    friend Rational operator/=(Rational& r1, const Rational r2);
    friend Rational operator*=(Rational& r1, const Rational r2);

    friend bool operator==(const Rational& r1, const Rational& r2);
    friend bool operator!=(const Rational& r1, const Rational& r2);
    friend bool operator<=(const Rational& r1, const Rational& r2);
    friend bool operator>=(const Rational& r1, const Rational& r2);
    friend bool operator<(const Rational& r1, const Rational& r2);
    friend bool operator>(const Rational& r1, const Rational& r2);
    friend Rational operator++(Rational& r);

};


#endif   // ----- #ifndef RATIONAL_H -----

